<#assign module="car"/>

<@override name="header">
<link rel="stylesheet" href="${ctx}/assets/css/datetimepicker.css">
<link rel="stylesheet" href="${ctx}/assets/css/jquery.Jcrop.css">
</@override>
<@override name="body">
	
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">上传广告图片（可选）</div>
				<div class="panel-body">
					<div style="float:left;width:200;margin-right:8px;">
						<p>广告图片</p>
						<div id="show_photo_div">
						    <img id="show_photo" width="400" height="300"/>
						</div>
						<p></p>
						<p>
						<button href="javascript:;" class="btn btn-primary" id="photo_upload_dialog">上传广告图片</button>
						</p>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	<div class="row">
		<div class="col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					添加广告
			    </div>
			    <div class="panel-body">
    				<form id="submit_form" action="${ctx}/advert/create" class="form-horizontal" method="post">
		               <input type="hidden" id="picture" name="picture" value="">
		               	<div class="form-group">
		                    <label class="col-sm-3 control-label"><em>*</em>广告名称：</label>
		                    <div class="col-sm-3">
		                    	<input class="form-control" id="adName" name="adName" type="text" required/>
		                    </div>
		                </div>
		                
		                <div class="form-group">
		                    <label class="col-sm-3 control-label"><em>*</em>链接地址：</label>
		                    <div class="col-sm-3">
								<input class="form-control" id="address" name="address" type="text" required/>
							</div>
		                </div>
		              
		                <div class="form-group" style="margin-left:10px;">
		                	<label class="col-sm-3 control-label"></label>
			                <input id="submit_button" type="submit" class="btn btn-primary" value="保存">
			                <input type="button" class="btn btn-default" onclick="window.location.href = '${ctx}/advert/list';" value="返回">
			            </div>
			            
					</form>
        		</div>
			</div>
		</div>
	</div>
	
	<div id="dialog_local_photo" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
		<div class="modal-dialog modal-lg" >
			 <div class="modal-content">
			 	<div class="modal-header">
	        		<button type="button" class="close close_modal" data-dismiss="modal" aria-hidden="true">&times;</button>
	        		<h4 class="modal-title">广告图片上传</h4>
	      		</div>
	      		<div class="modal-body" >
	      			<div class="row" >
	      				<div class="col-xs-12">
	      					<div class="form-group">
					      		<div class="caption" style="height:40px;">
							        <p>
								        <button href="javascript:;" class="btn btn-primary" id="photolocalsnap">本地上传</button>
								        <input style="display:none;" type="file" name="pic1" id="photoFile" accept=".bmp,.gif,.jpeg,.jpg,.png">
								    </p>
							    </div>
					           <div id="photoImg_div" style="width:800px;height:600px;display:table-cell;text-align:center;">
							    	
							    </div>
					        </div>
	      				</div>
	      				
	      				<#--
	      				<div class="col-xs-3">
		        			<div id="photoImg_container" style="width:200px;height:150px;overflow:hidden;margin-top:40px;">
		        		
		        			</div>
		        		</div>
		        		-->
		        		<div class="col-xs-12">
					      	<div class="form-group">
					      		<div class="caption">
							        <p>
								        <button href="javascript:;" id="photo_ok" class="btn btn-primary">确认</button>
							        </p>
							    </div>
					        </div>
				        </div>
				        
	      			</div>
	      		</div>
			 </div>
		</div>
	</div>

</@override>
<@override name="footer">
<script src="${ctx}/assets/js/ajaxfileupload.js"></script>
<script src="${ctx}/assets/js/advertcamera.js"></script>
<script src="${ctx}/assets/js/swfobject.js"></script>
<script src="${ctx}/assets/js/jquery.Jcrop.js"></script>
<script type="text/javascript">

	<#if message??>
		$.scojs_message("${message}", $.scojs_message.TYPE_ERROR);
	</#if>

	$(document).ready(function(){
		//提交表单
		$("#submit_form").submit(function(){
			if($("#picture").val()==""){
				$.scojs_message("请上传广告图片", $.scojs_message.TYPE_ERROR);
				return false;
			}
			return true;
		});
		
	});
</script>
</@override>
<@extends name="../layout.ftl"/>